<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link type="text/css"  rel="stylesheet" href="css/tablecss.css" >
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<title>Insert title here</title>
<script>

	function pingfen(length){
		var total = 0;
		var q;
		var a;
		var errorInfo="";
		for(var i=1;i<=length;i++){
			q = $("input:radio[name='q"+i+"'][checked='checked']").val();
			a = $("input:hidden[name='a"+i+"']").val();
			if(q==a){
				total+=10;
			}else{
				errorInfo+="题号："+i+":应为"+a+",您的答案为"+q+"\n";
			}
		}
		alert("您的得分是:"+total+"\n"+errorInfo);
	}


</script>
</head>
<body>
	<table class="imagetable">
	
		<tr><td colspan="4">选择题(每题10分)</td></tr>
		<c:forEach items="${questions }" var="qt" varStatus="status">
			<tr>
				<th colspan="4">${status.index+1 }、    ${qt.title }<input type="hidden" name="a${status.index+1 }" value="${qt.answer }"></th>
			</tr>
			<tr>
				<td><input name="q${status.index+1 }" type="radio" value="A">${qt.optionA }</td>
				<td><input name="q${status.index+1 }" type="radio" value="B">${qt.optionB }</td>
				<td><input name="q${status.index+1 }" type="radio" value="C">${qt.optionC }</td>
				<td><input name="q${status.index+1 }" type="radio" value="D">${qt.optionD }</td>
			</tr>
		</c:forEach>
		<tr>
			<td colspan="4"><input type="button" onclick="pingfen(${fn:length(questions)})" value="完成"></td>
		</tr>
	</table>



</body>
</html>